package com.syntax.relatorio;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;

public class DataSource implements JRDataSource {
	private Map<String, Object> mapa = new HashMap<String, Object>();
	private Iterator<Map<String, Object>> iterator;
	
	public DataSource(List<Map<String, Object>> lista)
	{
		iterator = lista.iterator();
	}
	
	public Object getFieldValue(JRField field) throws JRException
	{
		Object value = mapa.get(field.getName());
		return value;
	}

	public boolean next() throws JRException
	{
		if (iterator != null && iterator.hasNext())
		{
			mapa = iterator.next();
			return true;
		}
		
		return false;
	}
}